from PythonUtils.websocket.WebSocketUtil import WebSocketUtil

if __name__ == "__main__":
    def on_open(ws):
        print(f"on_open:{ws}")


    def on_message(ws, message):
        print(f"on_message:{ws}-{message}")


    def on_error(ws, error):
        print(f"on_error:{ws}-{error}")


    def on_close(ws):
        print(f"on_close:{ws}")

    wsUtil = WebSocketUtil()
    wsUtil.connect('ws://127.0.0.1:2114/webSocket/admin:1')
    wsUtil.onOpen = on_open
    wsUtil.onMessage = on_message
    wsUtil.onError = on_error
    wsUtil.onClose = on_close
    while True:
        message = input("please:")
        if (message!="q"):
            wsUtil.ws.send(message)
        else:
            wsUtil.disConnect()
            break